<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
 * App\Models\Resident
 *
 * @property int $id
 * @property int $user_id 用户id
 * @property string $real_name 姓名
 * @property string $nick_name 昵称
 * @property string $avatar 头像
 * @property int $gender 性别；1：男，2：女，3：未知
 * @property int $birthday 出生日期
 * @property string $tel 手机号
 * @property string $alternate_phone 备用手机号
 * @property string $nation 民族
 * @property string $card_no 身份证号
 * @property int $is_party 是否党员；0：否，1：是，2：未知
 * @property int $join_time 入党时间
 * @property int $education 学历；1：小学，2：初中，3：高中，4：中专，5：技校，6：专科，7：本科，8：研究生，9：硕士，10：博士
 * @property string|null $service_unit 服务单位
 * @property string|null $position 职业
 * @property string $face_photo 人脸识别照片
 * @property string $id_photo_front 身份证照片正面
 * @property string $id_photo_back 身份证照片背面
 * @property string $bracelet 手环序列号
 * @property int $bracelet_act 0无，1已下发，2已激活
 * @property string $pass_card 门禁卡卡号
 * @property int $height 身高
 * @property int $weight 体重
 * @property int $step 目标（记步）
 * @property int $consume 目标（消耗）
 * @property int $mileage 目标（里程）
 * @property int $create_time 创建时间
 * @property int $update_time 更新时间
 * @method static \Illuminate\Database\Eloquent\Builder|Resident newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Resident newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Resident query()
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereAlternatePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereAvatar($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereBirthday($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereBracelet($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereBraceletAct($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereCardNo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereConsume($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereCreateTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereEducation($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereFacePhoto($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereGender($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereHeight($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereIdPhotoBack($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereIdPhotoFront($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereIsParty($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereJoinTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereMileage($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereNation($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereNickName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident wherePassCard($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident wherePosition($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereRealName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereServiceUnit($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereStep($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereTel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereUpdateTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Resident whereWeight($value)
 * @mixin \Eloquent
 */
class Resident extends Model
{
    use HasFactory;
    protected $table = 'resident';
    protected $appends=['test1'];

    //生日日期设置
    public function getBirthdayAttribute($value)
    {
        return !empty($value)?date('Y-m-d', $value):'';
    }

    public function getTest1Attribute()
    {
        return 'test1'.$this->attributes['birthday'];
    }

    //关联查询
    public function sign()
    {
        return $this->hasMany(ResidentSign::class,'user_id','user_id');
    }
}
